package com.ruoyi.advertisement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.advertisement.domain.BoleBannerAd;
import com.ruoyi.advertisement.service.IBoleBannerAdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 首页轮播图广告管理Controller
 * 
 * @author Wujiale
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/swiper/ad")
@Api("广告")
public class BoleBannerAdController extends BaseController
{
    @Autowired
    private IBoleBannerAdService boleBannerAdService;

    /**
     * 查询首页轮播图广告管理列表
     */
//    @PreAuthorize("@ss.hasPermi('advertisement:ad:list')")
    @ApiOperation("获取用户列表")
    @GetMapping("/list")
    public TableDataInfo list(BoleBannerAd boleBannerAd)
    {
        startPage();
        List<BoleBannerAd> list = boleBannerAdService.selectBoleBannerAdList(boleBannerAd);
        return getDataTable(list);
    }

    /**
     * 导出首页轮播图广告管理列表
     */
    @PreAuthorize("@ss.hasPermi('advertisement:ad:export')")
    @Log(title = "首页轮播图广告管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BoleBannerAd boleBannerAd)
    {
        List<BoleBannerAd> list = boleBannerAdService.selectBoleBannerAdList(boleBannerAd);
        ExcelUtil<BoleBannerAd> util = new ExcelUtil<BoleBannerAd>(BoleBannerAd.class);
        util.exportExcel(response, list, "首页轮播图广告管理数据");
    }

    /**
     * 获取首页轮播图广告管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('advertisement:ad:query')")
    @GetMapping(value = "/{bannerAdId}")
    public AjaxResult getInfo(@PathVariable("bannerAdId") String bannerAdId)
    {
        return success(boleBannerAdService.selectBoleBannerAdByBannerAdId(bannerAdId));
    }

    /**
     * 新增首页轮播图广告管理
     */
    @PreAuthorize("@ss.hasPermi('advertisement:ad:add')")
    @Log(title = "首页轮播图广告管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BoleBannerAd boleBannerAd)
    {
        return toAjax(boleBannerAdService.insertBoleBannerAd(boleBannerAd));
    }

    /**
     * 修改首页轮播图广告管理
     */
    @PreAuthorize("@ss.hasPermi('advertisement:ad:edit')")
    @Log(title = "首页轮播图广告管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BoleBannerAd boleBannerAd)
    {
        return toAjax(boleBannerAdService.updateBoleBannerAd(boleBannerAd));
    }

    /**
     * 删除首页轮播图广告管理
     */
    @PreAuthorize("@ss.hasPermi('advertisement:ad:remove')")
    @Log(title = "首页轮播图广告管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bannerAdIds}")
    public AjaxResult remove(@PathVariable String[] bannerAdIds)
    {
        return toAjax(boleBannerAdService.deleteBoleBannerAdByBannerAdIds(bannerAdIds));
    }
}
